const {ccclass, property} = cc._decorator;

@ccclass
export default class ResLoading extends cc.Component {

    @property(cc.Label)
    label: cc.Label = null;

    static _resLoadingComp: ResLoading = null;

    onLoad () {
        cc.game.addPersistRootNode(this.node);
        ResLoading._resLoadingComp = this;
        this.node.active = false;
    }

    protected onEnable(): void {
        this.node.position = cc.Canvas.instance.node.position;
    }

    
    static show (text:string) {
        ResLoading._resLoadingComp.node.active = true;
        ResLoading._resLoadingComp.label.string = text;
    }

    static hide () {
        ResLoading._resLoadingComp.node.active = false;
    }
}
